import { createApp } from 'vue';
import Cookies from 'js-cookie';
import ElementPlus from 'element-plus';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import './permission'; // permission control
import 'element-plus/dist/index.css';
import './utils/theme.js';
import './assets/icon/iconfont.css';
import consts from './common/manager/const';
import Highcharts from 'highcharts/highstock';
import HighchartsMore from 'highcharts/highcharts-more';
import locale from 'element-plus/es/locale/lang/zh-cn';
import ProcessedImage from '@/components/ProcessedImage/index.vue';
import 'default-passive-events';
import constants from '@/constants';
const { ZY_TYPE, XK_TYPE } = constants;
HighchartsMore(Highcharts);
import App from './App.vue';
import router from './router';
import store from './store';
console.log(process.env.VUE_APP_API_BASE_URL, '===');
const app = createApp(App);

// 设置全局属性
app.config.globalProperties.$const = consts;
app.config.globalProperties.$XK_TYPE = XK_TYPE;
app.config.globalProperties.$ZY_TYPE = ZY_TYPE;
// 注册 ElementPlus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.component('ProcessedImage', ProcessedImage);
// 使用插件和挂载
app
  .use(ElementPlus, {
    locale: locale,
    size: Cookies.get('size') || 'default', // 读取用户偏好设置
  })
  .use(store)
  .use(router)
  .mount('#app');
